<%--
  Created by IntelliJ IDEA.
  User: liushuo
  Date: 2021/8/14
  Time: 23:03
  To change this template use File | Settings | File Templates.
--%>
<%--JSP指令,用来设置页面的一些信息--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<html>
<head>
    <c:set var="context" value="${pageContext.servletContext.contextPath}"/>
    <title>index.jsp</title>
</head>
<body>
<h1>index.jsp</h1>
<a href="${context}/testExceptionHandler2">testExceptionHandler2</a>
<br>
<hr>
<a href="${context}/testExceptionHandler">testExceptionHandler</a>
<br>
<hr>
<a href="${context}/interceptor/testInterceptor">testInterceptor</a>
<br>
<hr>
<a href="${context}/testDown">testDown</a>
<br>
<hr>
<form method="post" action="${context}/testUpLoad" enctype="multipart/form-data">
    1<input type="file" name="photo">
    2<input type="submit" value="upload">
</form>

<br>
<hr>
<a href="${context}/success">success</a>
<br>
<hr>
<a href="${context}/user/1">get user/{1}</a>
<br>
<hr>
<form action="${context}/user" method="post">
    <input name="username" value="zhansan" type="text">
    <input name="password" value="123132" type="text">
    <input name="age" value="18" type="text">
    <input type="submit" value="submit">
</form>
<br>
<hr>
<form action="${context}/user" method="post">
    <input name="_method" value="PUT" type="hidden">
    <input name="username" value="zhansan" type="text">
    <input name="password" value="9999" type="text">
    <input name="age" value="999" type="text">
    <input type="submit" value="submit">
</form>
<br>
<hr>
<form action="${context}/user" method="post">
    <input name="_method" value="DELETE" type="hidden">
    <input name="id" value="11" type="text">
    <input type="submit" value="submit">

</form>
<br>
<hr>
<a id="deleteU" @click="deleteUser" href="${context}/user/13">delete user/{13}</a>
<form id="deleteForm" method="post">
    <input name="_method" value="DELETE" type="hidden">
</form>
<br>
<hr>
<a href="${context}/testResponse">testResponse</a>
<br>
<hr>
<a href="${context}/testResponseBody">testResponseBody</a>
<br>
<hr>
<a href="${context}/testResponseUser">testResponseUser</a>

<div id="app">
    <a @click="testAxios" href="${context}/testAxios">testAxios</a>
</div>


<script type="text/javascript" src="${context}/static/js/vue.js"></script>
<script type="text/javascript">
    var vue = new Vue({
        el: "#deleteU",
        methods: {
            deleteUser: function (event) {
                var deleteForm = document.getElementById("deleteForm");
                //触发点击事件
                deleteForm.action = event.target.href;
                deleteForm.submit();
                //取消超链接默认行为
                event.preventDefault()
            }
        }
    });
</script>
<script type="text/javascript" src="${context}/static/js/axios.min.js"></script>
<script type="text/javascript">
    var vue2 = new Vue({
        el: "#app",
        methods: {
            testAxios: function (event) {
                axios({
                    method: "post",
                    url: event.target.href,
                    params: {
                        username: "axios 888"
                    }
                }).then(function (response) {
                    alert(response.data)
                });
                //取消超链接默认行为
                event.preventDefault()
            }
        }
    });
</script>
</body>
</html>
